let app = getApp()
Page({
    data: {
        val: ''
    },
    inputConfirm(e) {
        let val = ''
        if (e.detail) {
            val = e.detail.value
        } else {
            val = e
        }
        wx.showLoading({
            title: '正在加载数据中.....',
        })
        wx.cloud.callFunction({
            name: 'cloudapi',
            data: {
                $url: "garbageTextSearch",
                text: val
            }
        }).then(res => {
            // console.log(res) 
            wx.hideLoading();
            if (res.result.message == "success") {
                this.setData({
                    dialogShow: true
                })
                let info = res.result.garbage_info[0]
                this.setData({
                    garbage: info
                })
            } else {
                return app.$util.errorToShow("不知道是什么垃圾")

            }
        })
    },
    closeDialog() {
        this.setData({
            dialogShow: false
        })
    },
})